import React, { Component } from 'react'
import { Breadcrumb } from 'antd'
import { withRouter } from 'react-router-dom'

const breadData={
    '/':[],
    '/home': ['首页'],
    '/users':['用户'],
    '/role':['角色管理'],
    '/products/categories':['商品管理','品种管理'],
    '/products/list':['商品管理','商品列表'],
    '/products/addList':['商品管理','添加商品'],
    '/products/updateList':['商品管理','修改商品'],
}
class TheBreadcrumb extends Component {

    get breadcrumbItem(){
        let path=this.props.history.location.pathname
        if (path) {
            if (path.includes('/products/list')) {
                path='/products/list'
            }
            return breadData[path].map(item=><Breadcrumb.Item key={item}>{item}</Breadcrumb.Item>)
        }
        return breadData[path].map(item=><Breadcrumb.Item>首页</Breadcrumb.Item>)
    }
    render() {
        return (
            <Breadcrumb>
                {this.breadcrumbItem}
            </Breadcrumb>
        )
    }
}

export default withRouter(TheBreadcrumb)
